
<div id="container" style="height: 100%"></div>

<script type="text/javascript">

    layui.use(['form', 'table','miniPage','element', 'axios','echarts'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            echarts=layui.echarts,
            miniPage = layui.miniPage;
        var axios = layui.axios;

        axios.post('user/queryTongjiList', {}).then(function(response){
            var data=response.data;
            var str="";//放置名称
            var str2=""//放置对应的数据
            for(var p in  data){
                str=str+data[p].name+",";
            }
            str=str.substring(0,str.length-1);
            var strResult=str.split(",");

            for(var p in  data){
                str2=str2+data[p].counts+",";
            }
            str2=str2.substring(0,str2.length-1);
            var strResult2=str2.split(",");


            var dom = document.getElementById("container");
            var myChart = echarts.init(dom);
            var app = {};

            var option;

            option = {
                xAxis: {
                    type: 'category',
                    data: strResult
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data:strResult2,
                    type: 'bar'
                }]
            };

            if (option && typeof option === 'object') {
                myChart.setOption(option);
            }



        })


    });
</script>
</body>
</html>
